<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="pragma" content="no-cache"/>
    <meta http-equiv="content-type" content="no-cache, must-revalidate"/>
    <meta http-equiv="expires" content="Wed, 26 Feb 1997 08:21:57 GMT"/>
    <title>公交车路线信息</title>
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <link href="css/my.css" rel="stylesheet">
    <link href="css/nav.css" rel="stylesheet">

    <style>
        [v-cloak] {
            display: none;
        }
    </style>
</head>
<body>
<div id="wrapper" v-cloak>
    <div class="nav-container-header">
        <div class="container" style="height: 100%">
            <div class="row" style="height: 100%">
                <div class="col-md-3"><img class="logo-img" src="/front/img/logo.png" alt="">
                    <div class="logo">公交查询系统</div>
                </div>
                <div class="col-md-7"><img class="header-img" src="/front/img/carousel/7.jpg" alt=""></div>
            </div>
        </div>
    </div>
    <div class="nav-container">
        <ul class="nav-item-box">
            <li><a class="nav-item" href="index.html">首页</a></li>
            <li><a class="nav-item" href="advertiserInfo.html">公告信息</a></li>
			<li><a class="nav-item active" href="pathInfo.html">公交车路线信息</a></li>
			<li><a class="nav-item" href="messageInfo.html">留言信息</a></li>

            <li><a class="nav-item" href="/end/page/index.html" target="_blank">进入后台系统</a></li>
        </ul>
        <div class="nav-right">
            <a class="nav-item" href="/end/page/login.html" target="_blank">登录</a>
            <a class="nav-item" href="/end/page/register.html" target="_blank">注册</a>
        </div>
    </div>
    <div class="container"  style="margin-top: 20px">
        <div class="col-md-12" style="margin-top: 20px; margin-bottom: 20px">
            班次：<input type="text" style="margin-right: 10px; width: 100px" placeholder="请输入班次" v-model="name" @keyup.enter="loadTable(1)">
            起始站：<input type="text" style="margin-right: 10px; width: 110px" placeholder="请输入起始站" v-model="start" @keyup.enter="loadTable(1)">
            终点站：<input type="text" style="margin-right: 10px; width: 110px" placeholder="请输入终点站" v-model="end" @keyup.enter="loadTable(1)">
            首班时间：<input type="text" style="margin-right: 10px; width: 100px" placeholder="如 07:00" v-model="startTime" @keyup.enter="loadTable(1)">
            末班时间：<input type="text" style="margin-right: 10px; width: 100px" placeholder="如 20:00" v-model="endTime" @keyup.enter="loadTable(1)">
            途径站点：<input type="text" style="margin-right: 10px; width: 120px" placeholder="请输入途径站点" v-model="station" @keyup.enter="loadTable(1)">
        </div>
        <div class="col-md-12">
            <table class="table table-striped table-bordered table-hover">
                <thead>
                <tr style="background-color: #cccccc">
                    <th style="width: 50px">ID</th>
					<th>班次</th>
					<th>首班车时间</th>
					<th>起始站</th>
					<th>终点站</th>
					<th>线路</th>
					<th>末班车时间</th>

                    <th>详情</th>
                </tr>
                </thead>
                <tbody>
                <tr v-for="(data,index) in tableData" :key="data.id">
                    <td>{{data.id}}</td>
					<td>{{data.name}}</td>
					<td>{{data.startTime}}</td>
					<td>{{data.start}}</td>
					<td>{{data.end}}</td>
					<td>{{data.path}}</td>
					<td>{{data.endTime}}</td>

                    <td><a :href=`pathInfoDetail.html?id=${data.id}` target="_blank">详情</a></td>
                </tr>
                </tbody>
            </table>
            <div style="text-align: center;">
                <nav aria-label="Page navigation example">
                    <ul class="pagination">
                        <li class="page-item" :class="{ disabled: preActive }">
                            <a class="page-link" href="javascript:void(0)"
                               @click="loadTable(pageInfo.pageNum - 1)">上一页</a>
                        </li>
                        <li class="page-item">
                            <a class="page-link" href="javascript:void(0)" v-if="pageInfo.pageNum > 1" @click="loadTable(pageInfo.pageNum - 1)">{{pageInfo.pageNum - 1}}</a>
                        </li>
                        <li class="page-item disabled">
                            <a class="page-link" aria-disabled="true" href="javascript:void(0)">{{pageInfo.pageNum}}</a>
                        </li>
                        <li class="page-item">
                            <a class="page-link" href="javascript:void(0)" v-if="pageInfo.hasNextPage" @click="loadTable(pageInfo.pageNum + 1)">{{pageInfo.pageNum + 1}}</a>
                        </li>
                        <li class="page-item" :class="{ disabled: nextActive }">
                            <a class="page-link" href="javascript:void(0)" @click="loadTable(pageInfo.hasNextPage? (pageInfo.pageNum + 1) : pageInfo.pageNum)">下一页</a>
                        </li>
                    </ul>
                </nav>
            </div>
        </div>
    </div>
</div>

<script src="js/jquery-1.10.2.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/jquery.metisMenu.js"></script>
<script src="js/vue2.6.11/axios.js"></script>
<script src="js/vue2.6.11/vue.min.js"></script>

<script>
    new Vue({
        el: '#wrapper',
        data: {
            name: '',
            start: '',
            end:'',
            startTime: '',
            endTime: '',
            station: '',

            tableData: [],
            pageInfo: {},
            preActive: true,
            nextActive: true
        },

        created: function() {
            this.loadTable(1);
        },

        methods: {
            loadTable(pageNum) {
                let url = '/pathInfo/page?pageNum=' + pageNum;
                if (this.name !== '') {
                    url += '&name=' + this.name;
                }
                if (this.start !== '') {
                    url += '&start=' + this.start;
                }
                if (this.end !== '') {
                    url += '&end=' + this.end;
                }
                if (this.startTime !== '') {
                    url += '&startTime=' + this.startTime;
                }
                if (this.endTime !== '') {
                    url += '&endTime=' + this.endTime;
                }
                if (this.station !== '') {
                    url += '&station=' + this.station;
                }
                axios.get(url).then(res => {
                    if (res.data.code === '0') {
                        this.tableData = res.data.data.list;
                        this.pageInfo = res.data.data;
                        this.preActive = !(this.pageInfo.hasPreviousPage);
                        this.nextActive = !(this.pageInfo.hasNextPage);
                    } else {
                        alert(res.data.msg);
                    }
                });
            }
        }
    })
</script>
</body>
</html>